<template>
    <el-table
            name="baseValidateTable"
            width="100%"
            :data="tableData">
        <el-table-column label="键名">
            <template slot-scope="scope">
                <el-input type="input" v-model="scope.row.keyName"></el-input>
            </template>
        </el-table-column>
        <el-table-column label="比较器">
            <template slot-scope="scope">
                <el-select v-model="scope.row.comparator" placeholder="请选择比较器"  style="width:100%;">
                    <el-option :label="item.label" :value="item.value" v-for="item in comparators" :key="item.value"></el-option>
                </el-select>
            </template>
        </el-table-column>
        <el-table-column label="健值类型">
            <template slot-scope="scope">
                <el-select v-model="scope.row.valueType" placeholder="请选择数据类型" style="width:100%;">
                    <el-option :label="item.label" :value="item.value" v-for="item in valueTypes" :key="item.value"></el-option>
                </el-select>
            </template>
        </el-table-column>
        <el-table-column label="键值">
            <template slot-scope="scope">
                <el-input type="input" v-model="scope.row.value"></el-input>
            </template>
        </el-table-column>
        <el-table-column
                label="操作"
                width="50">
            <template  slot-scope="scope">
                <el-button type="danger" icon="el-icon-delete" circle size="mini" @click="$emit('removeRowByIndex', tableData, scope.$index)"></el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
    export default {
        name: "base-Validate-Table",
        props: {
            tableData: {
                require: true,
                type: Array,
            }
        },
        data: function () {
            return {
                comparators: [{label: "equals(相等)", value: "equals"}, {label: "contains(包含)", value: "contains"}, {label: "contained_by(被包含)", value: "contained_by"},{label: "type_match(类型匹配)", value: "type_match"},{label: "less_than(小于)", value: "less_than"}, {label: "less_than_or_equals(小于等于)", value: "less_than_or_equals"},{label: "greater_than(大于)", value: "greater_than"},{label: "greater_than_or_equals(大于等于)", value: "greater_than_or_equals"}, {label: "not_equals(不等于)", value: "not_equals"}, {label: "string_equals(字符串相等)", value: "string_equals"}, {label: "length_equals(长度相等)", value: "length_equals"}, {label: "length_greater_than(长度大于)", value: "length_greater_than"}, {label: "length_greater_than_or_equals(长度大于登录)", value: "length_greater_than_or_equals"},  {label: "startswith(某字符串开头)", value: "startswith"}, {label: "endswith(某字符串结尾)", value: "endswith"},{label: "regex_match(正则匹配)", value: "regex_match"}],
                valueTypes: [{label: "string", value: "string"}, {label: "int", value: "int"}, {label: "float", value: "float"}],

            }
        },

    }

</script>

<style scoped>

</style>